package com.example.neusoft.yuejian_12.Fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.neusoft.yuejian_12.Adapter.ClassDetailAdapter;
import com.example.neusoft.yuejian_12.JavaBean.Club;
import com.example.neusoft.yuejian_12.Listener.ClubDetailListener;
import com.example.neusoft.yuejian_12.Model.ClubModel;
import com.example.neusoft.yuejian_12.R;

import java.util.List;

/**
 * Created by admin on 2017/10/24.
 */

public class ClassFragment extends Fragment {
    private List<Club.ClubcourseEntity> Data;
    private  String id;
    private Club info;
    private RecyclerView recyclerView;
    private Context mContext;

   ClubDetailListener clubDetailListener = new ClubDetailListener() {
        @Override
        public void onResponse(Club listBean) {
            info = listBean;
            initData();

        }

        @Override
        public void onFail(String msg) {

        }
    };

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        View view = inflater.inflate(R.layout.activity_class_fragment,container,false);
        recyclerView = (RecyclerView) view.findViewById(R.id.rv_class);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));//设置布局
        final Bundle bundle =getActivity().getIntent().getExtras();
        id = bundle.getString("id");
        ClubModel model = new ClubModel();
        model.getclass(id, clubDetailListener);
        return view;
    }
  private void initData(){

      Data = info.getClubcourse();
      recyclerView.setAdapter(new ClassDetailAdapter(getActivity(),Data));

    }


}
